package cn.com.zsc.schedule;

import java.util.Hashtable;
import java.util.Properties;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.Trigger;

public class SchedulerUtils {
	public static Scheduler scheduler =null;
	public static Hashtable tiggerStatusMap=new Hashtable();
	public static Hashtable jobStatusMap=new Hashtable();
	public static Properties props = new Properties();
	public SchedulerUtils()
	{
				
	}
	
	/**
	 * 向现有任务队列中增加一个新任务
	 * @param jobDetail
	 * 任务
	 * @param trigger
	 * 触发器
	 * @return
	 * 执行成功返回true，失败返回false
	 */
	public static boolean AddJob(JobDetail jobDetail,Trigger trigger){
		try{
			SchedulerUtils.scheduler.scheduleJob(jobDetail, trigger);
			return true;
		}catch(Exception ex){
			ex.printStackTrace();
			return false;
		}
	}
	
	/**
	 * 移除当前任务队列中的某个任务。
	 * @param jobName
	 * 任务名称
	 * @param jobGroup
	 * 任务所属分组
	 * @return
	 * 执行成功返回true，失败返回false
	 */
	public static boolean RemoveJob(String jobName,String jobGroup){
		try{
			SchedulerUtils.scheduler.deleteJob(jobName, jobGroup);
			return true;
		}catch(Exception ex){
			ex.printStackTrace();
			return false;
		}
	}
	
	
}
